﻿using Newtonsoft.Json;
using RXY_Mall.AdminApi.Alipay;
using RXY_Mall.AdminApi.Common;
using RXY_Mall.Core;
using RXY_Mall.Core.Tool;
using RXY_Mall.Data;
using RXY_Mall.Domain;
using RXY_Mall.Services;
using RXY_Mall.Services.Finance;
using RXY_Mall.Services.Goods;
using RXY_Mall.Services.Order;
using RXY_Mall.Services.Order.Dto;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Script.Serialization;
using WebApi.OutputCache.V2;

namespace RXY_Mall.AdminApi.Controllers
{
    /// <summary>
    /// 订单接口
    /// </summary>
    [RoutePrefix("Order")]
    [ApiSecurityFilter]
    public class OrderController : BaseApiController
    {
        private RXY_MallContext db;
        private IOrderService orderService;

        public OrderController()
        {
            db = new RXY_MallContext();
            orderService = new OrderService();
        }

        /// <summary>
        /// 订单发货
        /// </summary>
        /// <param name="input">erp订单号</param>
        /// <returns></returns>
        [HttpPost]
        [Route("ShipmentOrder")]
        public async Task<ResponseService<OrderStatusOutput>> ShipmentOrder(OrderStatusInput input)
        {
            return await orderService.ShipmentOrder(input.api_order_no_list);
        }

        /// <summary>
        /// 订单收货
        /// </summary>
        /// <param name="input">erp订单号</param>
        /// <returns></returns>
        [HttpPost]
        [Route("ReceiveOrder")]
        public async Task<ResponseService<OrderStatusOutput>> ReceiveOrder(OrderStatusInput input)
        {
            return await orderService.ReceiveOrder(input.api_order_no_list);
        }

        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="input">erp订单号</param>
        /// <returns></returns>
        [HttpPost]
        [Route("CancelOrder")]
        public async Task<ResponseService<OrderStatusOutput>> CancelOrder(OrderStatusInput input)
        {
            return await orderService.CancelOrder(input.api_order_no_list);
        }
    }
}
